const app = getApp();
import HttpRequst from '../../../utils/httpRequst.js'
import API from '../../../utils/config.js'
Page({
  data: {
    biz_id:"",
    fromwhere:"",
    dataInfo:""
  },
  onLoad: function (options) {
   
    var that=this;
    this.setData({
      biz_id: options.biz_id,
      fromwhere: options.fromwhere ? options.fromwhere :""
    });

   
    
    //HttpRequst(loading,url,发送header类型, sessionId, params,method, ask, function (res){})
    HttpRequst(true, API.biz, 1, app.getUkey(), { biz_id: this.data.biz_id},"POST",false,function(res){
     
      that.setData({
        dataInfo:res.data.info
      })
      // wx.setNavigationBarTitle({
      //   title: res.data.info.name//页面标题为路由参数
      // })
    });
  },
  makePhoneCall: function (e) {
    wx.makePhoneCall({
      phoneNumber: this.data.dataInfo.tel,
    })
  },
  goBuyNav:function(){
      if(this.data.dataInfo.stepd==6){
          wx.navigateTo({
            url: '/pages/index/paybill/paybill?biz_id=' + this.data.biz_id,
          })
      } else if (this.data.dataInfo.stepd ==-1){
        wx.showModal({
          title: '提示',
          content: '您未登录，暂时无法进行购买',
          cancelText:'我知道了',
          confirmText:'立即登录',
          success: function (res) {
            if (res.confirm) {
              wx.navigateTo({
                url: '/pages/index/login/login',
              })
            } else if (res.cancel) {
              
            }
          }
        })
      }else{
        wx.showModal({
          title: '提示',
          content: '贷款发放尚未审核完成，请耐心等待！',
          showCancel:false,
          confirmText: '我知道了',
          success: function (res) {
            if (res.confirm) {
             
            } else if (res.cancel) {

            }
          }
        })
      }
  },
  openLocation:function(){
    wx.openLocation({
      latitude: this.data.dataInfo.lat,
      longitude: this.data.dataInfo.lng,
      scale:18,
      name: this.data.dataInfo.name,
      address: this.data.dataInfo.addr
    })

  },
  onUnload:function(){
    if (this.data.fromwhere=="payresult"){
      wx.reLaunch({
        url:"/pages/index/index/index"
      })
    }
  }
  
})